package com.molichuxing.gateway.bff.permission.services.impl;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.dto.TabDto;
import com.molichuxing.framework.result.ResponseResult;
import com.molichuxing.framework.utils.CollectionUtils;
import com.molichuxing.framework.utils.StringUtil;
import com.molichuxing.gateway.bff.permission.convertor.Convert;
import com.molichuxing.gateway.bff.permission.entity.response.DesenseVo;
import com.molichuxing.gateway.bff.permission.entity.response.GroupBindDesenseVo;
import com.molichuxing.gateway.bff.permission.entity.response.GroupBindResourceVo;
import com.molichuxing.gateway.bff.permission.entity.response.GroupVo;
import com.molichuxing.gateway.bff.permission.services.GroupBffService;
import com.molichuxing.gateway.bff.permission.services.ResourceBffService;
import com.molichuxing.gateway.property.OperatorEnum;
import com.molichuxing.gateway.utils.TokenUtil;
import com.molichuxing.gateway.utils.entity.UserEntity;
import com.molichuxing.services.business.service.DesenseBizService;
import com.molichuxing.services.business.service.GroupBizService;
import com.molichuxing.services.business.service.ResourceBizService;
import com.molichuxing.services.infrastructure.dto.response.DealerDto;
import com.molichuxing.services.infrastructure.dto.response.response.GroupDto;
import com.molichuxing.services.infrastructure.dto.response.response.GroupResourceDto;
import com.molichuxing.services.infrastructure.dto.response.response.ResourceDto;
import com.molichuxing.services.infrastructure.service.*;
import com.molichuxing.services.property.GroupSystemTypeEnum;
import com.molichuxing.services.property.SystemTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

@Service("resourceBffService")
public class ResourceBffServiceImpl implements ResourceBffService {

    private static final Logger logger = LoggerFactory.getLogger(ResourceBffServiceImpl.class);

    @Resource
    private ResourceBizService resourceBizService;

    @Resource
    private TokenUtil tokenUtil;

    /**
     * 获取左侧菜单树
     * @return
     */
    @Override
    public List<ResourceDto> getMenuTree() {
        UserEntity currentLoginUser = tokenUtil.getUser();
        if (currentLoginUser == null) {
            logger.error("获取左侧菜单树，当前用户没有登录 currentLoginUser :: {}", currentLoginUser);
            return null;
        }

        return resourceBizService.getMenuTree(currentLoginUser.getAccountId());
    }
}

